//
//  ViewController.m
//  2.18
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;

@end


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)Btn1Pressed:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"窗口1" message:@"你是白痴吗" delegate:self cancelButtonTitle:@"董死魔犬是" otherButtonTitles:@"白然巨屎是", nil];
      [alertView show];
}

- (IBAction)Btn2Pressed:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"窗口2" message:@"中午吃什么" delegate:self cancelButtonTitle:@"肉" otherButtonTitles:@"屎",@"不吃",nil];
    [alertView show];
}

- (IBAction)Btn3Pressed:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"窗口3" message:@"请输入用户名 密码！" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消",nil];
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"用户点了第几个按钮 %i , 用户点的按钮信息 %@",buttonIndex+1,[alertView buttonTitleAtIndex:buttonIndex]);
    
    if ([alertView.title isEqualToString:@"窗口3"]) {
        NSString *info = [NSString stringWithFormat:@"用户名:%@，密码:%@",[alertView textFieldAtIndex:0].text,[alertView textFieldAtIndex:1].text];
        self.infoLabel.text = info;

    }
}
- (IBAction)Btn4Pressed:(UIButton *)sender
{
    UIActionSheet *sheet =[[UIActionSheet alloc] initWithTitle:@"窗口4" delegate:self cancelButtonTitle:@"你去吧 我吃过了" destructiveButtonTitle:@"好的 一起去吃KFC" otherButtonTitles:@"好的 一起去吃大保健", nil];
    [sheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"用户选择第几个按钮 %i，用户选择的按钮信息 %@",buttonIndex +1,[actionSheet buttonTitleAtIndex:buttonIndex]);
    NSLog(@"操作表的标题%@",actionSheet.title);
    if (buttonIndex == actionSheet.destructiveButtonIndex) {
        NSLog(@"用户选择了destructiveBtn");
    }
    else if (buttonIndex == actionSheet.cancelButtonIndex)
    {
        NSLog(@"用户选择了cancelBtn");
    }
        
}


// 练习:
// 1. 分析整个应用中当前有多少对象?罗列出来

/*
 UIApplication(1)
 AppDelegate(1)
 UIWindow(1)
UIViewController(1)
 
 btn(4) label(1)
 UIalertView(3) UIactionSheet(1)
 button.title(3) actionSheet.title(1)
 UIView(1) 

 */

// 2. 使用Reveal查看程序结构
// 3. 使用纯代码实现本程序



@end
